#include<iostream>
#include <locale>
#include<fstream>
using namespace std;
struct student {
  //std::string name;
  char name[36];
  int age;
  char sex;
};

int main()
{ 
  try
  {

    struct student d;
    ofstream outfile("student.txt", ios::out | ios::binary);
    outfile.imbue(std::locale("zh_CN.utf8"));
    struct student tom = { "李ooooooooooooooooijifw",16,'M'};
    cout << sizeof(tom)<<endl;
    outfile.write(reinterpret_cast<char*>(&tom), sizeof(tom));
    outfile.close();
    
   ifstream infile("student.txt", ios::in | ios::binary);
   infile.imbue(std::locale("zh_CN.utf8"));
   cout << sizeof(d)<<endl;
   while(infile.read((char*)&d, sizeof(d)));
   cout <<  d.name << "/" <<  d.age << "/" << d.sex << endl;
   infile.close();
  
  }catch (const std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
    return -1;
  } catch (...) {
    std::cerr << "Unknown error occurred." << std::endl;
    return -1;
  }
  return 0;
    
}
